/**
* @Title: ServerObjectInitializer.java
* @Package com.an.objecttran
* @Description: TODO(用一句话描述该文件做什么)
* @author antch,861710865@qq.com
* @date 2017年7月26日 下午3:08:11
* @version V1.0
*/

package com.an.objecttran;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.serialization.ClassResolvers;
import io.netty.handler.codec.serialization.ObjectDecoder;
import io.netty.handler.codec.string.StringEncoder;

/**
 * @ClassName: ServerObjectInitializer
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author antch,861710865@qq.com
 * @date 2017年7月26日 下午3:08:11
 *
 */

public class ServerObjectInitializer extends ChannelInitializer<SocketChannel> {

	@Override
	protected void initChannel(SocketChannel ch) throws Exception {
		// TODO Auto-generated method stub
		ChannelPipeline pipeline = ch.pipeline();
		pipeline.addLast("objectdecord",
				new ObjectDecoder(ClassResolvers.cacheDisabled(this.getClass().getClassLoader())));

		pipeline.addLast("strencoder",new StringEncoder());
		pipeline.addLast("handler", new ServerObjectHandler());
	}

}
